package insight.google.game.era.data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.jdo.annotations.ForeignKey;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.NotPersistent;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
import javax.persistence.PersistenceContext;

import org.datanucleus.store.mapped.IdentifierCase;
import org.datanucleus.store.mapped.IdentifierType;
import org.directwebremoting.annotations.DataTransferObject;
import org.directwebremoting.annotations.RemoteProperty;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;
import com.sun.org.apache.bcel.internal.generic.ARRAYLENGTH;

@DataTransferObject
@PersistenceCapable(identityType=IdentityType.APPLICATION,detachable="true")
public class UserHistory{


	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@PrimaryKey
	private Key id;

	@RemoteProperty
	@Persistent
	private Date loginTime = new Date();

	@RemoteProperty
	@Persistent
	private Date logoutTime;

	@RemoteProperty
	@Persistent
	private int noOfGamePlayed = 0;

//	@RemoteProperty
	@Persistent
	private Key userId;
	
	@RemoteProperty
	@Persistent
	private String userName;

	
	@RemoteProperty
//	@Persistent(mappedBy="userHistory",)
	@NotPersistent
	private List<UserGameHistory> userGameHistoryList = new	 ArrayList<UserGameHistory>();

	public Key getId() {
		return id;
	}

	public void setId(Key id) {
		this.id = id;
	}

	 public Key getUserId() {
		 return userId;
	 }
	
	 public void setUserId(Key userId) {
		 this.userId = userId;
	 }

	public Date getLoginTime() {
		return loginTime;
	}

	
	public void setLoginTime(Date loginTime) {
		this.loginTime = loginTime;
	}

	public Date getLogoutTime() {
		return logoutTime;
	}

	public void setLogoutTime(Date logoutTime) {
		this.logoutTime = logoutTime;
	}

	public int getNoOfGamePlayed() {
		return noOfGamePlayed;
	}

	public void setNoOfGamePlayed(int noOfGamePlayed) {
		this.noOfGamePlayed = noOfGamePlayed;
	}

	public List<UserGameHistory> getUserGameHistoryList() {
		return userGameHistoryList;
	}

	public void setUserGameHistoryList(List<UserGameHistory> gameUserHistoryList) {
		this.userGameHistoryList = gameUserHistoryList;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	
	@RemoteProperty
	public String getUserHistoryId() {
		return KeyFactory.keyToString(id);
	}

}
